package com.xinzhi.controller;

import com.xinzhi.pojo.Appraisal;
import com.xinzhi.pojo.Poinos;
import com.xinzhi.pojo.Reason;
import com.xinzhi.service.AppraisalService;
import com.xinzhi.service.PoinosService;
import com.xinzhi.service.ReasonService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
/**
 * 特殊加分申请查询接口
 */
public class AppraisalController {
    @Autowired
    private ReasonService rensonService;
    @Autowired
    private AppraisalService appraisalService;
    @Autowired
    private PoinosService poinosService;

    /**
     * 特殊加分申请查询接口
     * @param object
     * @return
     */
    @GetMapping("/getAppraisalByObject")
    public Result getAppraisalByObject(String object){
        return appraisalService.getAppraisalByObject(object);
    }


    /**
     * 特殊加分修改接口
     */
    @PostMapping("/updateReason")
    public Result updateReason(@RequestBody Reason add) {
        return poinosService. updateReason(add);
    }


    /**
     * 特殊加分申请的新增接口
     */
    @PostMapping("/index")
    public Result index(@RequestParam String poinexe, @RequestParam Integer  extra) {
        // 调用service层的方法
        Result result = rensonService.addScore(poinexe, extra);
        return Result.ok(result);
    }

    /**
     * 特殊扣分申请修改接口
     */

    @PostMapping ("/updatePoinos")
    public Result updatePoinos(@RequestBody Poinos poinos) {
        return poinosService. updatePoinos(poinos);
    }
}
